﻿
namespace _5E.Infrastructure.DateTime
{
    public static class DateTimeExtensionMethod
    {
        public const string DATETIME_FORMAT = "yyyy-MM-dd";
        public const string FULL_DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";

        public static string ToDateTimeString(this System.DateTime dateTime, string format = DATETIME_FORMAT)
        {
            return dateTime.ToString(format);
        }

        public static string ToDateTimeString(this System.DateTime? dateTime, string format = DATETIME_FORMAT)
        {
            return dateTime.HasValue ? dateTime.Value.ToString(format) : string.Empty;
        }
    }
}
